package agh.tk.markuptranslation;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;

import org.antlr.runtime.ANTLRInputStream;
import org.antlr.runtime.CommonTokenStream;


public class MainDokuWiki {
	public static DokuWikiParser createDokuWikiParser(InputStream input) throws IOException {
		ANTLRInputStream antlrInputStream = new ANTLRInputStream(input);
		DokuWikiLexer lexer = new DokuWikiLexer(antlrInputStream);
		CommonTokenStream commonTokenStream = new CommonTokenStream(lexer) ;
		DokuWikiParser parser = new DokuWikiParser(commonTokenStream) ;
		return parser;
	}
	
	/**
	 * @param args
	 */
	public static void main(String[] args) {
		try 
		{
			DokuWikiParser parser = createDokuWikiParser(new FileInputStream(new File("dokuWiki.example")));
			DokuWikiParser.start_return result= parser.start();
			IComponent component = result.value ;
			System.out.println("-----------------------------------txt2tags-------------------------------------") ;
			System.out.println(component.toTxt2tags()) ;
			System.out.println("-----------------------------------dokuwiki-------------------------------------") ;
			System.out.println(component.toDokuWiki()) ;
			System.out.println("-------------------------MEDIA WIKI-------------------------------------") ;
			System.out.println(component.toMediaWiki()) ;
			System.out.println("---------------------------HTML-----------------------------------------") ;
			System.out.println(component.toHTML()) ;
		}
		catch (FileNotFoundException e) 
		{
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (org.antlr.runtime.RecognitionException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}

	}

}
